﻿using System;
using System.Xml.Serialization;
using System.Xml;

namespace VMDS.Business.Processes
{
    public static class XmlTool
    {

        public static void Save(string filename, object data)
        {
            //Сериализуем полученное
             
            XmlWriter writer = new XmlTextWriter(filename, System.Text.Encoding.UTF8);
            XmlSerializer serializer=new XmlSerializer(data.GetType());
            // XmlSerializer serializer = new XmlSerializer(typeof(settings));
            serializer.Serialize(writer, data);
            writer.Close();

        }
        public static dynamic Load(string filename, Type type)
        {
            XmlReader reader = new XmlTextReader(filename);
            XmlSerializer serializer=new XmlSerializer(type);
            dynamic sd = serializer.Deserialize(reader);
            reader.Close();
            return sd;

        }
    }
}
